Skip to content

Conversation

@Ulthran
Copy link
Contributor

@Ulthran Ulthran commented Jan 31, 2026

Motivation

  • Provide a safe utility to remove an isolate and all downstream records (aliquots, assemblies, QC, taxonomic assignments, contaminants, antimicrobials) in one operation.
  • Expose the removal workflow as a CLI command so operators can remove isolates from the database with optional confirmation.

Description

  • Added marc_db/remove.py which implements _summarize_isolate and remove_isolate to summarize and delete related records in a transactional manner.
  • remove_isolate deletes downstream rows in this order: Antimicrobial, Contaminant, TaxonomicAssignment, AssemblyQC, Assembly, Aliquot, and finally Isolate, using bulk .delete(synchronize_session=False) calls and a nested transaction with proper rollback on errors.
  • The function prints a summary of affected rows and prompts for confirmation (skippable with yes=True) and accepts an injectable input_fn for non-interactive testing.
  • Integrated the utility into the CLI by importing remove_isolate and adding a remove subcommand to marc_db.cli that calls remove_isolate after create_database and get_session.

Testing

  • No automated tests were run on the modified code.

Codex Task

Copilot AI review requested due to automatic review settings January 31, 2026 15:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a utility and CLI entry point to safely remove a single isolate and all of its downstream records from the database in a single transactional operation.

Changes:

  • Added marc_db/remove.py implementing _summarize_isolate to report counts of related records and remove_isolate to delete antimicrobials, contaminants, taxonomic assignments, QC records, assemblies, aliquots, and the isolate itself within a transaction, with optional user confirmation and injectable input.
  • Extended marc_db.cli with a remove subcommand that wires database initialization and session creation to remove_isolate, exposing isolate removal via the command-line interface.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
marc_db/remove.py Implements the new transactional isolate-removal workflow and helper summarization logic used before deletion.
marc_db/cli.py Adds a remove CLI subcommand and help text, integrating the new remove_isolate function with the existing CLI entrypoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Ulthran Ulthran merged commit 494ebd9 into main Jan 31, 2026
4 checks passed
@Ulthran Ulthran deleted the codex/add-utility-to-remove-an-isolate branch January 31, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant